const path = require("path");
const MiniCss = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const MODULE_NAME = "kuyuan_hb";
module.exports = {
    mode: "development", // development production
    entry: {
        setting: "./src/setting"
    },
    output: {
        path:path.dirname(__dirname)+"/"+MODULE_NAME+"/dist/admin/",
        filename:"[name].js",
        publicPath:"../addons/"+MODULE_NAME+"/dist/admin/"
    },
    module:{
        rules:[
            {
                test:/\.(png|jpeg|jpg|gif|svg|eot|ttf|woff|woff2)$/,
                use:{
                    loader:'file-loader',
                    options:{
                        name:'image/[name]-[hash:6].[ext]'
                    }
                }
            },
            {
                test:/\.less$/i,
                use: [
                    {
                        loader: MiniCss.loader,
                    },
                    {
                        loader: "css-loader",
                    },
                    {
                        loader: "less-loader",
                        options: {
                            lessOptions: {
                                strictMath: true,
                            },
                        },
                    }
                ]
            }
        ]
    },
    optimization: {
        minimize: true,
        splitChunks:{
            name:"common",
            chunks:"initial"
        }
    },
    plugins:[
        new CleanWebpackPlugin(),
        new MiniCss({filename:"[name].css"}),
    ],
    resolve:{
        alias:{
            "vue":"vue/dist/vue.common.js",
            "@":path.dirname(__dirname)+"/admin/util"
        }
    }
}